package com.chunuo.mvc;

import com.chunuo.configuration.starter.AutoConfiguration;
import com.chunuo.mvc.controller.UserController;
import com.chunuo.mvc.entity.SysUser;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * 类的作用
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-12-23 20:05
 */
public class MvcApplication  {


    public static void main(String[] args) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

        AutoConfiguration autoConfiguration = AutoConfiguration.newInstance();
        UserController userController = autoConfiguration.getBean(UserController.class);

        SysUser sysUser = new SysUser();
        sysUser.setUsername("555");
        sysUser.setPassword("123456");
        userController.userService.saveOrUpdate(sysUser);
        System.out.println(sysUser);

        sysUser.setUsername("999");
        sysUser.setPassword("654321");
        userController.userService.saveOrUpdate(sysUser);

        userController.userService.delete(sysUser);

        List<SysUser> sysUserList = userController.userService.findSysUserList();
        System.out.println(sysUserList);

        SysUser sysUserById = userController.userService.findSysUserById("803f1b68dac44bac");
        System.out.println(sysUserById);

        String username = userController.userService.findUserNameById("803f1b68dac44bac");
        System.out.println(username);


//        int count = userController.userService.deleteSysUserByUsername("555");
//        System.out.println(count);

    }


}
